﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Xml;
using HZ.MBSM.DBUtility;
public partial class Manage_DropChild : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Request["Value"] != null)
        {
            try
            {
                string state = this.Request.QueryString["Value"];
                string sort = this.Request.QueryString["vsort"];
                string strselet = "", insert = "";
                insert = " if not exists (select 1  from  Goodsothers where Otname='" + state + "') insert Goodsothers([Otname],[Otsort]) select '" + state + "'," + sort;
                strselet = "select  Otid, Otname from Goodsothers where Otsort=" + sort;
               
                Db db = new Db();
                db.Command(insert);
                db.Close();
                HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新", "Goodsothers", insert, "../Magage/goodsupdate.aspx", "修改其他表", "");
                SqlDataAdapter da = new SqlDataAdapter(strselet, db.ConnectionString);
                DataSet ds = new DataSet("Goodsothers");
                da.Fill(ds);
                XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;
                writer.IndentChar = ' ';
                ds.WriteXml(writer);
                writer.Flush();
                writer.Close();
              //  HttpContext.Current.ApplicationInstance.CompleteRequest();
                  Response.End();
            }
            catch (Exception eg)
            {
               // Response.Write("<script>alert('" + eg + "')<script>");
            }

        }
    }
}
